$(document).ready(function () {
    var newsSwiper = new Swiper('#m-news', {
        autoplay: 5000,
        loop: true
    });
    $("#m-news .swiper-arrow-left").on('click', function () {
        newsSwiper.slidePrev();
    });
    $("#m-news .swiper-arrow-right").on('click', function () {
        newsSwiper.slideNext();
    });
    $("#m-news").on('mouseout', function () {
        newsSwiper.startAutoplay();
    })
    var knowledgeSwiper = new Swiper('#m-knowledge', {
        autoplay: 0,
        loop: true,
        pagination: '#knowledge-pagination',
        paginationClickable: true,
        onSlideChangeEnd: function (swiper) {
            var index = swiper.activeIndex;
            // console.info(index);
            //   $(".block-knowledge .m-bottom").find("a").removeClass("g-title-color");
            //$(".block-knowledge .m-bottom").find("a").eq(index-2).toggleClass("g-title-color");
        }
    });
    $("#m-knowledge .swiper-arrow-left").on('click', function () {
        knowledgeSwiper.slidePrev();
    });
    $("#m-knowledge .swiper-arrow-right").on('click', function () {
        knowledgeSwiper.slideNext();
    });
    $("#m-knowledge").on('mouseout', function () {
        knowledgeSwiper.startAutoplay();
    })

    var banner_swiper = new Swiper('#banner-slider', {
        autoplay: 6000,
        loop: true,
        autoplayDisableOnInteraction: false,
        effect: 'fade',
        fade: {
            crossFade: true,
        },
        // 如果需要分页器
        pagination: '#banner-pagination',

        // 如果需要前进后退按钮
        nextButton: '#banner-button-next',
        prevButton: '#banner-button-prev',
        onSlideChangeStart: function (swiper) {
            var index = swiper.activeIndex //切换结束时，告诉我现在是第几个slide
            var target = $("#banner-slider").find(".swiper-slide-active").find(".m_box");//当前活动的slider
            var target2 = $("#banner-slider").find(".swiper-slide").find(".m_box");
            var targetImg = $("#banner-slider").find(".swiper-slide-active").find('img');
            // console.info('img:',targetImg.attr('src'));
            if (index != 1) {
                targetImg.removeClass('banner-animation-img');
                targetImg.addClass('banner-animation-img');
                target2.children(".desc").children("div").attr('class', '');
                target2.children(".desc").children("a").attr('class', '');
            }
            if (index == 2) {

                target.children(".desc").children("div").addClass('banner-animation2');
                target.children(".desc").children("a").addClass('banner-animation2-btn');
            }
            if (index == 3) {
                target.children(".desc").children("div").addClass('banner-animation3');
                target.children(".desc").children("a").addClass('banner-animation3-btn m-box-3a');
            }
            if (index == 4) {
                target.children(".desc").children("div").addClass('banner-animation4');
                target.children(".desc").children("a").addClass('banner-animation4-btn');
            }
            if (index == 5) {
                target.children(".desc").children("div").addClass('banner-animation2');
                target.children(".desc").children("a").addClass('banner-animation2-btn');
            }
            if (index == 6) {//实际上是第一个
                target.children(".desc").children("div").addClass('banner-animation1');
                target.children(".desc").children("a").addClass('banner-animation1-btn');
            }
        }
        // onSlideChangeStart: function(swiper){
        //
        //     var target2=$("#banner-slider").find(".swiper-slide").find(".m_box").children(".desc")
        //     target2.children("div").attr('class','');
        //     target2.children("a").attr('class','');
        // }
    });

    var friendLinkCarousel = $('.owl-carousel').owlCarousel({
        loop: true,
        rewind:true,
        autoplay: true,
        dots: false,
        margin: 10,
        nav: false,
        responsive: {
            0: {
                items: 1
            },
            600: {
                items: 3
            },
            1000: {
                items: 5
            }
        }
    })

})